package com.Dao;

import com.entity.Application;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * Created by Administrator on 2017/3/11.
 */
public class ApplicationDao {
    private Session session;
    Transaction tran=null;
    //增加一个报名表
    public void addApplication(Application app){
        session=DBAcess.getSession();
        try {
            tran = session.beginTransaction();
            //存入对象
            session.save(app);
            tran.commit();
        }catch (Exception e){
            //事务回滚
            if(tran!=null) tran.rollback();
            e.printStackTrace();
        }finally {
            session.close();
        }
    }
}
